package com.mew.slots.core.game.mnyys;

import com.mew.common.entity.game.WinFree;
import com.mew.common.rest.bo.GameSession;
import com.mew.common.vo.UserSessionVO;
import com.mew.slots.core.common.handler.AbstractBetHandler;
import com.mew.slots.core.common.handler.SlotsHandler;
import com.mew.slots.core.common.messge.response.SlotsBonusPlayResponseMessage;
import com.mew.slots.core.common.messge.response.SlotsPlayResponseMessage;
import com.mew.slots.core.common.utils.SlotsGameUtil;
import com.mew.slots.core.common.vo.StrategyGameVO;
import com.mew.slots.core.game.mnyys.roller.MnyysXml;
import com.mew.slots.core.game.mnyys.service.MnyysBonusService;
import com.mew.slots.core.game.mnyys.service.MnyysService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author King.Song
 * @Date 2020/11/9 0009
 **/
@Service
@SlotsHandler(value = "MNYYS")
@Slf4j
public class MnyysHandler extends AbstractBetHandler {

    private MnyysService service=new MnyysService();
    private MnyysBonusService bonusService=new MnyysBonusService();
    @Override
    public void specialCheck(StrategyGameVO gameVO, GameSession userVO) {}

    @Override
    public SlotsPlayResponseMessage play(StrategyGameVO gameVO, GameSession userVO) {

        return service.Ready(gameVO);
    }

    @Override
    public SlotsBonusPlayResponseMessage playBonus(StrategyGameVO gameVO, GameSession userVO) {
        return bonusService.play(gameVO);
    }

    @Override
    public void readRoller() throws Exception{
        MnyysXml.getInstance().init();
    }

    public static void main(String[] args)throws Exception{
        MnyysHandler handler=new MnyysHandler();
        handler.readRoller();

        long allBet=0;
        long allWin=0;
        for (int i = 0; i <100000; i++) {
            StrategyGameVO player = SlotsGameUtil.buildTestStrategyGameVO();
            player.setLineNumber(80);
            player.setBetNumber(80);
            SlotsPlayResponseMessage res = handler.play(player, null);
            allBet+=(res.getBetNumber()*player.getLineNumber());
            allWin+=res.getWinCoin();

        }
        System.out.println(allWin);
        System.out.println(allBet);
        System.out.println(1.0d*allWin/allBet);

    }
}
